package com.anrongtec.zcpt.utils;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.widget.TextView;

import com.anrongtec.zcpt.R;
import com.anrongtec.zcpt.ui.activity.AppDownManagerActivity;

/**
 * 作者：liuhui on 2017/2/13 14:13
 * 邮箱：liu594545591@126.com
 * 描述：SnackbarUtil
 */

public class SnackbarUtil {

    /**
     * 显示已经添加到下载列表,  点击按钮跳转到下载页面
     * @param activity
     * @param button
     */
    public static void showSnackbar(final Activity activity, final View button) {
        Snackbar snackbar = Snackbar.make(button, "已添加到下载列表", 3000);
        View snackbarView = snackbar.getView();
        if(snackbarView!=null){
            ((TextView) snackbarView.findViewById(R.id.snackbar_text)).setTextColor(Color.WHITE);//获取Snackbar的message控件，修改字体颜色
        }
        snackbar.setAction("查看", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                activity.startActivity(new Intent(activity, AppDownManagerActivity.class));
            }
        }).show();
    }

}

